//
//  Service+UserService.m
//  CarService
//
//  Created by Nimo.Yu on 15/1/30.
//  Copyright (c) 2015年 lexingsoft. All rights reserved.
//

#import "Service+UserService.h"
#import "DataManager.h"
#import "Services.h"
#import "NetworkConfig.h"
//#import "UMessage.h"

#define kProductName @"Umibus_iOS"

@implementation ServiceManager(UserService)
//自动登录
+(void)autoLoginSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)()) failure
{
    NSString *name=@"";
    NSString *passwd=@"";
    
    if ([NSString checkNullString:[DataManager sharedInstance].userId]) {
        //匿名用户
    }else
    {
        name=[DataManager sharedInstance].userId;
        passwd=[DataManager sharedInstance].userPassword;
    }
    
    NSString *path = @"/auth/public/signin";
    NSDictionary *parameterDict = @{@"loginId":name,
                                    @"password":passwd,
                                    @"product":kProductName,
                                    @"agency":@"",
                                    };
    [NetworkClient postRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        if (![NSString checkNullString:name])
        {
//            [UMessage setAlias:name type:@"userId" response:^(id responseObject, NSError *error) {
//            }];
        }
        if ([dataObject isKindOfClass:[NSDictionary class]]) {
            NSString *token=dataObject[@"token"];
            NSString *userId=dataObject[@"userId"];
            if (token) {
                [[DataManager sharedInstance] setUserToken:token];
                [[DataManager sharedInstance] setUsersId:userId];
                if (![name isEqualToString:@""]) {
                    [[DataManager sharedInstance] saveUserInfo];
                }
            }
        }
        [self getUserInfoSuccess:^(NSDictionary *data) {
        } failure:^{
        }];
        success(dataObject);
    } failure:^(id resultDict) {
        failure();
    }];
}

///登录
+ (void)loginWithPhone:(NSString*)phoneNum passWord:(NSString*)passWord success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *failure)) failure
{
    NSString *path = @"/auth/public/signin";
    NSDictionary *parameterDict = @{@"loginId":phoneNum,
                                    @"password":passWord,
                                    @"product":kProductName,
                                    @"openId":@"",
                                    @"agency":@"",
                                    };
    [NetworkClient postRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        if (dataObject) {
            NSString *token=dataObject[@"token"];
            if (token) {
                [[DataManager sharedInstance] setUserToken:token];
//                if ([DataManager sharedInstance].tempUserId) {
                    [DataManager sharedInstance].userId=phoneNum;
                    [DataManager sharedInstance].userPassword=passWord;
//                }
                [[DataManager sharedInstance] saveUserInfo];
            }
        }
        [self getUserInfoSuccess:^(NSDictionary *data) {
        } failure:^{
        }];
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];

}


///注册登录
+(void)loginFirstWithPhone:(NSString *)phoneNum passwd:(NSString *)passwd code:(NSString *)code smsId:(NSString *)smsId originalInviteCode:(NSString*)originalInviteCode success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *failure)) failure
{
    [DataManager sharedInstance].tempUserId=phoneNum;
    [DataManager sharedInstance].tempPassword=passwd;
    
    
    NSString *path = @"/auth/public/signup";
    NSDictionary *parameterDict = @{
                                    @"smsId":smsId,
                                    @"password":passwd,
                                    @"loginId":phoneNum,
                                    @"identifyingCode":code,
                                    @"product":kProductName,
                                    @"originalInviteCode":originalInviteCode
                                    };
    [NetworkClient postRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        if (dataObject) {
            NSString *token=dataObject[@"token"];
            if (token) {
                [[DataManager sharedInstance] setUserToken:token];
                if ([DataManager sharedInstance].tempUserId) {
                    [DataManager sharedInstance].userId=phoneNum;
                    [DataManager sharedInstance].userPassword=passwd;
                }
                [[DataManager sharedInstance] saveUserInfo];
            }
        }
        [self getUserInfoSuccess:^(NSDictionary *data) {
        } failure:^{
        }];
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

//发送短信验证码(授权)
+(void)getMessageCodeWithPhone:(NSString *)phoneNum success:(void(^)(NSDictionary *data)) success failure:(void(^)()) failure
{
    NSString *path = @"/sms/identifyingcode/mobile";
    
    NSDictionary *parameterDict = @{@"phoneNum":phoneNum,
                                    @"smsType":@"AUTH",
                                    };
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure();
    }];
}

///根据userID获取用户信息
+ (void)getUserInfoWithId:(NSString *)userId success:(void(^)(NSDictionary *data)) success failure:(void(^)()) failure
{
    NSString *path =[NSString stringWithFormat:@"/workerinfo/phone/%@",userId];
    NSDictionary *parameterDict = nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure();
    }];
}

///获取用户信息
+ (NSDictionary *)getUserInfoSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)()) failure
{
    if(![[DataManager sharedInstance] isLogin])
    {
        return nil;
    }
    NSString *path = @"/publicusers/me";
    NSDictionary *parameterDict = nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        if ([dataObject isKindOfClass:[NSDictionary class]]) {
            [DataManager sharedInstance].userInfoDic=dataObject;
            [DataManager sharedInstance].workId=[(NSDictionary *)dataObject objectForKey:@"workerId"];
            [DataManager sharedInstance].usersId = [(NSDictionary*)dataObject objectForKey:@"userId"];
            [DataManager sharedInstance].nickName=[(NSDictionary *)dataObject objectForKey:@"nickName"];
            [DataManager sharedInstance].userName=[(NSDictionary *)dataObject objectForKey:@"userName"];
            [DataManager sharedInstance].singinCount=[[(NSDictionary *)dataObject objectForKey:@"singin"] longLongValue];
            [DataManager sharedInstance].isSinginToday=[[(NSDictionary *)dataObject objectForKey:@"hassignup"] isEqualToString:@"Y"];
            [DataManager sharedInstance].userSequenceNBR = [(NSDictionary *)dataObject objectForKey:@"sequenceNBR"];
            [DataManager sharedInstance].proxy = [(NSDictionary *)dataObject objectForKey:@"isProxy"];
            [DataManager sharedInstance].isReservation = [(NSDictionary *)dataObject objectForKey:@"isReservation"];
            [DataManager sharedInstance].userType=[(NSDictionary *)dataObject objectForKey:@"publicUserType"];
            [[DataManager sharedInstance] saveUserInfo];
            
            NSLog(@"isReservation:%@",[(NSDictionary *)dataObject objectForKey:@"isReservation"]);
            success(dataObject);
        }else{
            failure();
        }
    } failure:^(id dataObject) {
        failure();
    }];
    return [DataManager sharedInstance].userInfoDic;
}

///更新用户信息
+ (void)refreshUserInfo:(NSDictionary *)userInfo success:(void(^)(NSDictionary *data)) success failure:(void(^)()) failure
{
    NSString * path = [NSString stringWithFormat:@"%@/%@",@"/publicusers",[DataManager sharedInstance].usersId];
    NSDictionary * dict = userInfo;
    [NetworkClient putRequest:path parameters:dict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict)
    {
        failure();
    }];
    
}

///更新用户头像
+ (void)updateHeaderImage:(UIImage *)image success:(void(^)(NSDictionary *data)) success failure:(void(^)()) failure
{
//    [ServiceManager uploadImage:image spaceType:StorageSpaceTypeAvatar success:^(NSDictionary *data) {
//        NSString *path = [NSString stringWithFormat:@"%@/%@",@"/publicusers",[DataManager sharedInstance].usersId];
//        NSDictionary * dict = @{@"avatar":data[@"key"]};
//        [NetworkClient putRequest:path parameters:dict NeedPrompt:YES success:^(id dataObject) {
//            success(dataObject);
//        } failure:^(id resultDict)
//         {
//             failure();
//         }];
//    } failure:^(NSDictionary *data) {
//        failure();
//    }];
}

///添加收货地址
+ (void)addAddress:(NSDictionary *)address success:(void (^)(NSDictionary *))success failure:(void (^)())failure
{
    NSString * path = [NSString stringWithFormat:@"/order/address"];
    NSDictionary * dict = address;
    [NetworkClient postRequest:path parameters:dict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure();
    }];
}
///删除收货地址
+(void)deleteAddress:(NSString *)NBR success:(void (^)(NSDictionary *))success failure:(void (^)())failure
{
    NSString * path = [NSString stringWithFormat:@"/order/address/%@",NBR];
    NSDictionary * dict = nil;
//    [NetworkClient getRequest:path parameters:dict NeedPrompt:YES success:^(id dataObject) {
//        success(dataObject);
//    } failure:^(id dataObject) {
//        failure();
//    }];
    
    [NetworkClient deleteRequest:path parameters:dict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure();
    }];
}

//+ (void)deleteAddress:(NSDictionary *)address success:(void (^)(NSDictionary *))success failure:(void (^)())failure
//{
//    NSString * path = [NSString stringWithFormat:@"/order/address/:sequenceNBR"];
//    NSDictionary * dict = address;
//    [NetworkClient getRequest:path parameters:dict NeedPrompt:YES success:^(id dataObject) {
//        success(dataObject);
//    } failure:^(id dataObject) {
//        failure();
//    }];
//}

///更新收货地址
+ (void)upDateAddress:(NSDictionary *)address sequenceNBR:(NSString*)NBR success:(void (^)(NSDictionary *))success failure:(void (^)())failure
{
    NSString * path = [NSString stringWithFormat:@"/order/address/%@",NBR];
    NSDictionary * dict = address;
    [NetworkClient putRequest:path parameters:dict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
        
    } failure:^(id resultDict) {
        failure();
    }];
    
    
}

///查询收货地址
+ (void)readAddress:(NSDictionary *)address success:(void (^)(NSDictionary *))success failure:(void (^)())failure
{
    NSString * path = [NSString stringWithFormat:@"/order/address"];
    NSDictionary * dict = address;
    [NetworkClient getRequest:path parameters:dict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure();
    }];
}

///获取默认收货地址
+ (void)getDefaultAddressSuccess:(void(^)(NSDictionary * data)) success failure:(void(^)()) failure
{
    if (![[DataManager sharedInstance] isLogin]) {
        return;
    }
    NSString * path = [NSString stringWithFormat:@"/order/address"];
    NSDictionary * dict = @{@"isDefault":@"Y"};
    [NetworkClient getRequest:path parameters:dict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure();
    }];
}

///查询当前用户借阅信息列表查询
+ (void)borrowBook:(NSUInteger)pageIndex success:(void(^)(NSDictionary *data))success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = @"/borrow/me";
    const int countPer = 20;
    NSDictionary * dict = @{@"length":@(countPer),
                            @"start":@(countPer*pageIndex)};
    [NetworkClient getRequest:path parameters:dict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
    
}
///意见反馈
+(void)sendReviewWithComment:(NSString *)comment success:(void(^)(NSDictionary *data)) success failure:(void(^)())failure
{
    NSString *path = @"/feedback";
    NSDictionary *parameterDict=@{@"content":comment,
                                  @"userId":[[DataManager sharedInstance]userId]};
    [NetworkClient postRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject)
    {
        failure();
    }];
}

///评价图书
+ (void)writeBookReviewWithComment:(NSString *)comment book:(NSString *)bookId orderSn:(NSString *)orderSn targetId:(NSString *)targetId success:(void(^)(NSDictionary *data)) success failure:(void(^)())failure
{
    NSString *path =@"/comment";
    NSDictionary *parameterDict=@{@"commentBody":comment,
                                  @"articleNo":bookId,
                                  @"targetType":@"BOOK",
                                  @"orderSn":orderSn,
                                  @"targetSequenceNbr":targetId};
    [NetworkClient postRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject)
     {
         failure();
     }];
}

///获取测试帐号
+(void)getTestAcountInfoSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)())failure
{
    NSString *path =STD_CHOICES_VALUE_URI;
    NSDictionary *parameterDict=@{@"dictCode":@"SPCNBR4IOS",
                                  @"agencyCode":@"SUPER_ADMIN",
                                  @"dictDataKey":@"IOS_TEST",};
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:NO success:^(id dataObject) {
        [DataManager sharedInstance].testAcount=dataObject[@"dictDataValue"];
        [DataManager sharedInstance].testAcountCode=dataObject[@"dictDataDesc"];
        success(dataObject);
    } failure:^(id dataObject) {
        failure();
    }];
}

///订单分享成功回调
+ (void)orderShareEventWithDic:(NSDictionary *)dicData success:(void(^)(NSDictionary *data)) success failure:(void(^)())failure
{
    NSString *path =@"/sharerecordsresources/sharerecords";
    NSDictionary *parameterDict=dicData;
    [NetworkClient postRequest:path parameters:parameterDict NeedPrompt:NO success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure();
    }];
}

///分享成功回调
+(void)shareEventWithDic:(NSDictionary *)dicData success:(void(^)(NSDictionary *data)) success failure:(void(^)())failure
{
    NSString *path =@"/publicevent/sharing";
    NSDictionary *parameterDict=dicData;
    [NetworkClient postRequest:path parameters:parameterDict NeedPrompt:NO success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure();
    }];
}

///查询虚拟账户信息
+ (void)getAccountInfoSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)())failure
{
    NSString *path = @"/account/me";
    NSDictionary *parameterDict=nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///查账单(分页)
+ (void)getAccountHistoryWithPageIndex:(NSUInteger)pageIndex success:(void(^)(NSDictionary *data)) success failure:(void(^)())failure
{
    NSString *path = @"/accountserial/public/page";
    const int countPer=20;
    NSDictionary *parameterDict=@{@"accountType":@"VIRTUAL",
                                  @"start":@(pageIndex*countPer),
                                  @"length":@(countPer)};
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///充值
+ (void)addMoney:(double)amount withPayChannel:(NSString *)payChannel success:(void(^)(NSDictionary *data)) success failure:(void(^)())failure
{
    NSString *path = @"/order/rechargeInfo";
    NSDictionary *parameterDict=@{@"amount":@(amount),
                                  @"channel":payChannel,};
    [NetworkClient postRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///获取充值方案
+ (void)getAddMoneySchemesSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)())failure
{
    NSString *path = @"/common/standardChoices/accountlevel/values/";
    NSDictionary *parameterDict=nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

+ (NSString *)getHostAddress{
    return [NetworkClient getHostAddress];
}

///分享地址拼接
+ (NSString *)shareAddres:(NSString *)type sequenceNBR:(NSString *)NBR labelKey:(NSString *)labelKey
{
    NSString *hostAddress=[self getHostAddress];
    NSString * path = [NSString stringWithFormat:@"%@/apis/sharelink?type=%@&id=%@&labelKey=%@",hostAddress,type,NBR,labelKey];
    return path;
}

///获取首页轮播广告
+ (void)getBannerAdvertisementsSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)())failure
{
    NSString *path = @"/advertisements/banner";
    NSDictionary *parameterDict=nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///初始化支付密码
+ (void)setupPayPassword:(NSString *)password success:(void(^)(NSDictionary *data)) success failure:(void(^)())failure
{
    if (password) {
        password=[NSString md5:password];
    }
    NSString *path = @"/account/paymentpasswrd/original";
    NSDictionary *parameterDict=@{@"paymentPassword":password};
    [NetworkClient putRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///修改支付密码
+ (void)changePassWord:(NSString*)passWord code:(NSString *)code phone:(NSString*)phone smsId:(NSString *)smsId success:(void(^)(NSDictionary *data)) success failure:(void(^)())failure
{
//    NSString * str = [NSString md5:passWord];
    NSString * path =[NSString stringWithFormat:@"/publicusers/me/password"];
    NSDictionary * dic = @{@"loginId":phone,
                           @"newPassword":passWord,
                           @"identifyingCode":code,
                           @"smsId":smsId};
    [NetworkClient putRequest:path parameters:dic NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///修改手机号
+ (void)changePhone:(NSString*)phone code:(NSString*)code passWord:(NSString*)passWord smsId:(NSString *)smsId success:(void(^)(NSDictionary *data)) success failure:(void(^)())failure
{
    NSString * path =[NSString stringWithFormat:@"/publicusers/me/mobilenumber"];
    NSDictionary * dic = @{@"loginId":phone,
                           @"password":passWord,
                           @"identifyingCode":code,
                           @"smsId":smsId};
    [NetworkClient putRequest:path parameters:dic NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];

}

///公网用户签到
+ (void)signInSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data))failure{
    NSString * path =[NSString stringWithFormat:@"/signrecords/userid?userId=%@",[DataManager sharedInstance].usersId];
    NSDictionary * dic = nil;
    [NetworkClient postRequest:path parameters:dic NeedPrompt:NO success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///查询用户积分详情
+ (void)getUserIntegralDetailWithPageIndex:(NSUInteger)pageIndex success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/scorechangerecord/page"];
    const int countPer=20;
    NSDictionary * dic = @{@"start":@(pageIndex*countPer),
                           @"length":@(countPer),
                           @"userId":[DataManager sharedInstance].usersId};
    [NetworkClient getRequest:path parameters:dic NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}

///提交医生证信息
+ (void)submitDoctorInfo:(NSDictionary *)doctorDic success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data))failure
{
    NSString * path =[NSString stringWithFormat:@"/publicusers/doctorinfo"];
    NSDictionary * dic = doctorDic;
    [NetworkClient postRequest:path parameters:dic NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///查询专家列表
+ (void)getAllDoctorWithPageIndex:(NSUInteger)pageIndex success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure{
    NSString * path =[NSString stringWithFormat:@"/publicusers/doctorinfo/page"];
    const int countPer=20;
    NSDictionary *parameterDict=@{@"start":@(pageIndex*countPer),
                                  @"length":@(countPer),
                                  @"isAudit":@"Y",
                                  @"auditStatus":@"Y"};
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///查询专家详情
+ (void)getDoctorInfoWithId:(NSString *)doctorId success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure{
    NSString * path =[NSString stringWithFormat:@"/1/publicusers/doctorinfo/%@",doctorId];
    NSDictionary *parameterDict=nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}
///用户查询自己的日记本
+ (void)getDiaryBookWithPageIndex:(NSUInteger)pageIndex success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/diarybook/page"];
    const int countPer=20;
    NSDictionary *parameterDict=@{@"start":@(pageIndex*countPer),
                                  @"length":@(countPer)};
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];

}
///判断用户提交认证医生
+ (void)isDoctorCertificationWithSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/publicusers/doctorinfo/iscommit"];
    NSDictionary * parameterDict = nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}
///判断推荐码是否有效
+ (void)isOrangeKeyWithSuccess:(NSString *)orangeKey success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    
    NSString * path = [NSString stringWithFormat:@"/publicusers/invitecode/%@/available",orangeKey];
    NSDictionary * parameterDict = nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}
///公网用户查询拿照之路
+ (void)getDirvingRoadInfoWithSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/licenseroad/"];
    NSDictionary * parameterDict = nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}

///公网用户获取个人二维码
+ (void)getUserTwoDimensionalCodeWithSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/publicusers/me/app/qrcode"];
    NSDictionary * parameterDict = nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}

///查询练车记录
+ (void)queryTrainingCarsRecordWithSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/order/subscribe/orderhistory?orderStatus=ARCHIVED"];
    NSDictionary * parameterDict = nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];

}
///获取学车推荐码
+ (void)getStudentCarCodeWithSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/publicusers/me/invitecode"];
    NSDictionary * parameterDict = nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}

///获取当前用户 推荐交定金 报名成功人数
+ (void)getUserSignUpNumberAndRecommendNumber:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/publicusers/invitedetail/me"];
    NSDictionary * parameterDict = nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}

///分页查询用户提现记录
+ (void)getUserWithdrawRecordWithPageIndex:(NSUInteger)pageIndex success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/cashoutapply/page"];
    const int countPer=20;
    NSDictionary *parameterDict=@{@"start":@(pageIndex*countPer),
                                  @"length":@(countPer)};
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///用户获取流量屯包
+ (void)getUserTrafficPackageWithType:(NSString*)type pageIndex:(NSInteger)pageIndex success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/order/callflow/flowpackag/page"];
    const int countPer=20;
    NSDictionary *parameterDict=@{@"isUsed":type,
                                  @"start":@(pageIndex*countPer),
                                  @"length":@(countPer)};
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
  
}
///查询用户账户信息
+ (void)getUserAccountInfoWithSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = @"/account/me";
    NSDictionary * parameterDict = nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}


///用户提现
+ (void)postUserWithdrawalWithApplayType:(NSString *)applayType transferAccount:(NSString *)transferAccount transferName:(NSString *)transferName
                               outAmount:(NSString *)outAmount openBank:(NSString *)openBank success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data))failure
{
    NSString * path =[NSString stringWithFormat:@"/cashoutapply"];
    NSDictionary * parameterDict = @{@"applayType":applayType,
                                     @"transferAccount":transferAccount,
                                     @"transferName":transferName,
                                     @"outAmount":outAmount,
                                     @"openBank":openBank};
    [NetworkClient postRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///用户获取提现银行
+ (void)getBankInfoWithSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path =[NSString stringWithFormat:@"/common/standardChoices/BANK/values"];
    NSDictionary * parameterDict = nil;
    
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}
///检测更新
+ (void)checkAppVersionSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/common/standardChoices/APPVERSION/values/ios_version"];
    NSDictionary * parameterDict = @{@"agencycode":@"SUPER_ADMIN"};

    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}

///检测是否需要强制升级
+ (void)checkIsNeedForceUpdateSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/common/standardChoices/app/isneedforceupdate"];
    NSDictionary * parameterDict = nil;
    
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}
///获取分享列表
+ (void)getShareListSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure{
    NSString * path = [NSString stringWithFormat:@"/common/standardChoices/isneedforceupdate"];
    NSDictionary * parameterDict = nil;
    
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}
///获取用户购买包过险信息
+ (void)getUserBuyInsurance:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/order/insure/me"];
    NSDictionary * parameterDict = nil;
    
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];

}

///获取教练教学时长
+ (void)getCocahWorkerInfoWithWordId:(NSString *)workId success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/workerinfo/statisticsinfo/%@",workId];
    NSDictionary * parameterDict = nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];

}

///获取学员各科目平均分数
+ (void)getStudentScottWithUserId:(NSString *)userId success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure{
    NSString * path = [NSString stringWithFormat:@"/customablitity/average/%@",userId];
    NSDictionary * parameterDict = nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}

///获取评分统计信息
+ (void)getStudentCommentWithUserId:(NSString *)userId success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/customablitity/count/%@",userId];
    NSDictionary * parameterDict = nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}
///获取客服电话
+ (void)getServicePhoneWithSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path =[NSString stringWithFormat:@"/common/standardChoices/servicePhone/values"];
    NSDictionary * parameterDict = nil;
    
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];

}

///上传注册信息
+ (void)postRegistrationInformationWithName:(NSString*)name phone:(NSString*)phone company:(NSString *)company department:(NSString*)department
                                 inviteCode:(NSString*)inviteCode success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = @"/userregisterapply";
    NSDictionary * parameterDict = @{@"userName":name,
                                     @"mobile":phone,
                                     @"company":company,
                                     @"department":department,
                                     @"inviteCode":inviteCode
                                     };
    [NetworkClient postRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///根据手机号码查询对应运营商信息
+ (void)getOperatorInfoWithMobile:(NSString *)mobile success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/operator/mobileinfo?mobile=%@",mobile];
    NSDictionary * parameterDict = @{@"mobile":mobile,
                                     };
    [NetworkClient postRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}


///用户下架自己的优惠券
+ (void)soldOutCouponsWithMarketSeq:(NSString*)marketSeq success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/couponmarket/public/takeoff/%@",marketSeq];
    NSDictionary * parameterDict = nil;
    [NetworkClient deleteRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}
///发布优惠券
+ (void)putawayCouponsWithCode:(NSString *)code salesPrice:(NSString*)salesPrice success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = @"/couponmarket/public/publish";
    NSDictionary * parameterDict = @{@"couponCode":code,
                                     @"salesPrice":salesPrice};
    [NetworkClient postRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];

}
///获取积分抵扣规则
+ (void)getScoreDeductionRuleSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = @"/scoreevent";
    NSDictionary * parameterDict = @{@"scoreEventType":@"DEDUCTION",
                                     };
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {

        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///获取签到奖励规则
+ (void)getScoreInCouponSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure{
    NSString * path = @"/scoreevent";
    NSDictionary * parameterDict = @{@"scoreEventType":@"SIGN_IN_COUPON",
                                     @"sidx":@"accumulateDays",
                                     };
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///用户购买优惠券
+ (void)userBuyCouponsWithPassWord:(NSString*)passWord amount:(NSString*)amount marketSeq:(NSString *)marketSeq success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = @"/order/coupon/submit";
    NSDictionary * parameterDict = @{@"amount":amount,
                                     @"passWord":passWord,
                                     @"payMethod":@"score",
                                     @"products":@{marketSeq:@"1"}
                                     };
    [ServiceManager getSubmitTokenSuccess:^(NSDictionary *data) {
        NSString *sToken=(NSString *)data;
        if ([sToken isKindOfClass:[NSString class]])
        {
            NSDictionary *headerParameters=@{@"submitToken":sToken};
            [NetworkClient postRequest:path parameters:parameterDict headerParameters:headerParameters needPrompt:YES success:^(id dataObject) {
                success(dataObject);
            } failure:^(id resultDict) {
                failure(resultDict);
            }];
        }
        
    } failure:^(NSDictionary *data) {
        
    }];
}

///获取提交令牌
+ (void)getSubmitTokenSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = @"/auth/submittoken";
    NSDictionary * parameterDict = nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {

        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}
///用户使用流量屯包
+ (void)userTrafficPackageWithOrderSn:(NSString*)orderSn userCount:(NSString*)userCount phone:(NSString*)phone passWord:(NSString*)passWord
                        phoneLocation:(NSString*)phoneLocation submitToken:(NSString*)submitToken success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = @"/order/callflow/use/package";
    NSDictionary * dic = @{@"orderSn":orderSn,
                           @"useCount":userCount,
                           @"phone":phone,
                           @"password":passWord,
                           @"phoneLocation":phoneLocation};
    NSDictionary *headerParameters=@{@"submitToken":submitToken};
    [NetworkClient putRequest:path parameters:dic headerParameters:headerParameters NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///用户查询流量包使用详情
+ (void)getTrafficePackageDetailWithOrderSn:(NSString*)orderSn success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/order/callflow/flowpackag/%@",orderSn];
    NSDictionary *parameterDict=nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
 
}

///获取积分可以抵扣的金额
+ (void)getScore2MoneyWithPrice:(NSString *)price productType:(NSString *)productType success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = @"/scoreevent/getScore2Money";
    NSDictionary *parameterDict=@{@"price":price,
                                  @"suitableType":productType};
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:NO success:^(id dataObject) {
        
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///用户购买理财产品
+ (void)postUserBuyFinancialProductWithPassWord:(NSString*)passWord amount:(NSString *)amount payMethod:(NSString*)payMethod market:(NSDictionary*)market success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = @"/order/fund";
    NSDictionary * parameterDict = @{@"amount":amount,
                                     @"passWord":passWord,
                                     @"payMethod":payMethod,
                                     @"products":market};
    [ServiceManager getSubmitTokenSuccess:^(NSDictionary *data) {
        NSString *sToken=(NSString *)data;
        if ([sToken isKindOfClass:[NSString class]])
        {
            NSDictionary *headerParameters=@{@"submitToken":sToken};
            [NetworkClient postRequest:path parameters:parameterDict headerParameters:headerParameters needPrompt:YES success:^(id dataObject) {
                success(dataObject);
            } failure:^(id resultDict) {
                failure(resultDict);
            }];
        }
    } failure:^(NSDictionary *data) {
        
    }];
}

///用户查询我的理财流量
+ (void)getUserMoneyFlowWithPageIndex:(NSInteger)pageIndex type:(NSString*)type success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = @"/funds/me";
    const int countPer=20;
    NSDictionary * parameteDict = @{@"start":@(pageIndex*countPer),
                                    @"length":@(countPer),
                                    @"accountStatus":type};
    [NetworkClient getRequest:path parameters:parameteDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}

///用户获取字典表年化收益
+ (void)getDictionaryListWithSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = @"/common/standardChoices/SYS_JOB/values/INTERESTRATE?agencyCode=SUPER_ADMIN";
    NSDictionary * parameterDict = nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}

///用户理财收益
+ (void)getUserFinancialBenefitsWithPageIndex:(NSInteger)pageIndex userId:(NSString*)usrId success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = @"/funds/profit/public/me";
    const int countPer=20;
    NSDictionary * parameteDict = @{@"start":@(pageIndex*countPer),
                                    @"length":@(countPer)};
    [NetworkClient getRequest:path parameters:parameteDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}

///获取智能缴费返还规则
+ (void)getBackRuleSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = @"/common/standardChoices/SYS_JOB/values/RECHARGE_DATE?agencyCode=SUPER_ADMIN";
    NSDictionary * parameterDict = nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}

///获取提现最小金额
+ (void)getCashoutLimitSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = @"/common/standardChoices/cashout_limit/values/cashout_limit?agencyCode=SUPER_ADMIN";
    NSDictionary * parameterDict = nil;
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}

///使用我的理财流量选择流量
+ (void)getSelectFinancialBenefitsTrafficWithOrderSn:(NSString*)orderSn success:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = [NSString stringWithFormat:@"/funds/products/%@",orderSn];
    NSDictionary * parameteDict = nil;
    [NetworkClient getRequest:path parameters:parameteDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id dataObject) {
        failure(dataObject);
    }];
}

///用户使用基金流量产品
+ (void)userFinancialBenefitsWithPhone:(NSString*)phone
                         phoneLocation:(NSString*)phoneLocation
                         fundProductId:(NSString*)fundProductId
                           chargeCount:(NSString*)chargeCount
                               success:(void(^)(NSDictionary *data)) success
                               failure:(void(^)(NSDictionary *data)) failure
{
    NSString *path = [NSString stringWithFormat:@"/funds/product/usage/%@?phone=%@&phoneLocation=%@&chargeCount=%@",fundProductId,phone,phoneLocation,chargeCount];
    NSDictionary * parameteDict = nil;
    [NetworkClient putRequest:path parameters:parameteDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///获取今天是否已经签到
+ (void)getIsSignTodaySuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString *path = @"/signrecords/today";
    NSDictionary * parameteDict = nil;
    [NetworkClient getRequest:path parameters:parameteDict NeedPrompt:YES success:^(id dataObject) {
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}

///获取购买成功之后赠送的积分规则
+ (void)getBuyGiftsScoreSuccess:(void(^)(NSDictionary *data)) success failure:(void(^)(NSDictionary *data)) failure
{
    NSString * path = @"/scoreevent";
    NSDictionary * parameterDict = @{@"scoreEventType":@"BUY_GIFTS",
                                     @"sidx":@"tradeUpperLimit",
                                     };
    [NetworkClient getRequest:path parameters:parameterDict NeedPrompt:YES success:^(id dataObject) {
        
        success(dataObject);
    } failure:^(id resultDict) {
        failure(resultDict);
    }];
}
@end

